﻿using System;
using System.Text;

using BizElements.Core;
using BizElements.Core.ProviderComponents;

namespace BizElements.Core.Firebird
{
    sealed class FirebirdTableRenderer : ITableRenderer
    {
        public void RenderTableName(IDbTable table, StringBuilder output)
        {
            // Special characters must be enclosed in quotes.
            bool hasSpecChars = TextUtil.HasSpecialChars(table.TableName);
            if (hasSpecChars)
                output.Append("\"");
            
            output.Append(table.TableName);
            if (hasSpecChars)
                output.Append("\"");
        }

        public void RenderAlias(IDbTable table, StringBuilder output)
        {
            // Special characters must be enclosed in quotes.
            bool hasSpecChars = TextUtil.HasSpecialChars(table.Alias);
            if (hasSpecChars)
                output.Append("\"");

            output.Append(table.Alias);
            if (hasSpecChars)
                output.Append("\"");
        }        
    }
}